<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
//    return $request->user();
//});


Route::match(['post','get'],'fileUpload','Controller@FileUploadApi')->name('fileUpload');

Route::group([
    'namespace'=>'Common',
    'prefix' => 'common'
], function ($router) {
    $router->any('sendCode', 'CommonController@sendCode');
});
/*
|****************************
| Api
| 客户端api路由
|****************************
*/
Route::group([
    'namespace'=>'Api',
//    'prefix' => 'api'
], function ($router) {
    $router->any('getAccessToken', 'AuthController@getAccessToken');
    #微信小程序登录
    $router->any('wxLogin', 'AuthController@wxLogin');
    #登录
    $router->any('login', 'AuthController@login');
    #注册
    $router->any('register', 'AuthController@register');
    #刷新token
    $router->any('refreshToken', 'AuthController@refreshToken')->middleware('auth:api');
    #退出登录
    $router->any('logout', 'AuthController@logout')->middleware('auth:api');
    #判断用户是否注册
    $router->any('whetherToRegister', 'AuthController@whetherToRegister');

    #需要授权的接口
    Route::group([
        'middleware' =>['auth:api'],
    ], function () {
        #用户
        Route::group([
            'namespace'=>'Users',
            'prefix' => 'users'
        ], function ($router) {
            #我的名片夹（我的名片）
            $router->any('businessCard', 'UsersController@businessCard');
            #更新名片
            $router->any('updateBusinessCard', 'UsersController@updateBusinessCard');
            #获取用户信息
            $router->any('getUserInfo', 'UsersController@getUserInfo');
            #实名认证
            $router->any('authentication', 'UsersController@authentication');
            #更新用户信息
            $router->any('updateUserInfo', 'UsersController@updateUserInfo');
            #申请交换名片
            $router->any('changeBusinessCard', 'UsersController@changeBusinessCard');
            #处理名片的交换
            $router->any('handleBusinessCard', 'UsersController@handleBusinessCard');
            #名片列表  交换名片  收到的
            $router->any('businessCardLists', 'UsersController@businessCardLists');
            //交换名片 发出的
            $router->any('initiateForCardLists', 'UsersController@initiateForCardLists');
            #拉黑（名片）
            $router->any('friendsBlock', 'UsersController@friendsBlock');
            //已经交换的名片列表
            $router->any('successCardLists', 'UsersController@SuccessCardLists');
            //校友片名详情
            $router->any('getCardInfo', 'UsersController@getCardInfo');
            //校友卡认证
            $router->any('alumniCardSign', 'UsersController@alumniCardSign');
            //校友列表
            $router->any('alumniList', 'UsersController@alumniList');
            //列表菜单
            $router->any('menuList', 'UsersController@menuList')->withoutMiddleware('auth:api');
        });
        #公共（banner、公告）
        Route::group([
            'namespace'=>'Common',
            'prefix' => 'common'
        ], function ($router) {
            # banner list
            $router->any('banner', 'CommonController@banner')->withoutMiddleware('auth:api');
            # banner detail
            $router->any('bannerDetail', 'CommonController@bannerDetail')->withoutMiddleware('auth:api');
            # notice list
            $router->any('notice', 'CommonController@notice')->withoutMiddleware('auth:api');
            # notice detail
            $router->any('noticeDetail', 'CommonController@noticeDetail')->withoutMiddleware('auth:api');
            # 系统设置
            $router->any('systemSetting', 'CommonController@systemSetting')->withoutMiddleware('auth:api');
        });
        #活动
        Route::group([
            'namespace'=>'Activity',
            'prefix' => 'activity'
        ], function ($router) {
            # list
            $router->any('list', 'ActivityController@lists')->withoutMiddleware('auth:api');
            # detail
            $router->any('detail', 'ActivityController@detail');
            # 活动报名
            $router->any('signUp', 'ActivityController@signUp');
            # 我的活动
            $router->any('myActivity', 'ActivityController@myActivity');
            // 申请活动
            $router->any('addActivity', 'ActivityController@addActivity');
        });
        #预约
        Route::group([
            'namespace'=>'Appointment',
            'prefix' => 'appointment'
        ], function ($router) {
            #提交预约
            $router->any('submit', 'AppointmentController@submit');
            #我的预约
            $router->any('mine', 'AppointmentController@mine');
            #校门类型
            $router->any('schoolGate', 'AppointmentController@schoolGate');
        });
        #组织
        Route::group([
            'namespace'=>'Organization',
            'prefix'=>'organization',
        ], function ($router) {
            # 全部组织
            $router->any('list', 'OrganizationController@lists');
            # 全部组织
            $router->any('detail', 'OrganizationController@detail');
            # 申请加入组织
            $router->any('join', 'OrganizationController@join');
            # 组织成员审核
            $router->any('examineAndVerify', 'OrganizationController@examineAndVerify');
            # 组织成员
            $router->any('members', 'OrganizationController@members');
//            #我的组织（已加入的）
            $router->any('mine', 'OrganizationController@mine');
            // 创建组织
            $router->any('addOrganization', 'OrganizationController@addOrganization');
            // 修改简介和联系方式
            $router->any('editOrganization', 'OrganizationController@editOrganization');
            //列表菜单
            $router->any('menuList', 'OrganizationController@menuList')->withoutMiddleware('auth:api');
            # 组织申请消息
            $router->any('applicationList', 'OrganizationController@applicationList');
            # 组织简介
            $router->any('introduction', 'OrganizationController@introduction')->withoutMiddleware('auth:api');
            # 转让组织transferStatus
            $router->any('transferStatus', 'OrganizationController@transferStatus');
        });
        #帖子
        Route::group([
            'namespace'=>'Post',
            'prefix' => 'post'
        ], function ($router) {
            # list
            $router->any('list', 'PostController@lists')->withoutMiddleware('auth:api');
            # detail
            $router->any('detail', 'PostController@detail');//->middleware('auth:api');
            $router->any('commentDetail', 'PostController@commentDetail');//->middleware('auth:api');
            # 帖子点赞
            $router->any('like', 'PostController@like');
            # 我的帖子（点赞的帖子）
            $router->any('mine', 'PostController@mine');

            // 组织趣贴
            $router->any('listByorg', 'PostController@listByorg')->withoutMiddleware('auth:api');
            $router->any('addOrgPost', 'PostController@addOrgPost');
            $router->any('addPostComment', 'PostController@addPostComment');
            $router->any('failPostComment', 'PostController@failPostComment');
            $router->any('menuPostComment', 'PostController@menuPostComment')->withoutMiddleware('auth:api');

        });
        #意见反馈
        Route::group([
            'namespace'=>'Feedback',
            'prefix' => 'feedback'
        ], function ($router) {
            #提交反馈
            $router->any('submit', 'FeedbackController@submit');
        });
        #校友卡
/*        Route::group([
            'namespace'=>'Alumnicard',
            'prefix' => 'alumnicard'
        ], function ($router) {
            #申请校友卡
            $router->any('submit', 'AlumnicardController@submit');
        });*/
    });

});
